package PTA;

import java.util.Scanner;

abstract class Animal4 {
    private String name;  //名字
    private int age;   //年龄
    public abstract void info();  //返回动物信息
    public abstract void speak(); //动物叫

    public Animal4(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
}
class Dog4 extends Animal4 {
    int violence;
    public Dog4(String name, int age, int violence) {
        super(name, age);
        this.violence = violence;
    }
    public Dog4(String name, int age) {
        super(name, age);
    }
    @Override
    public void info() {
        System.out.println("该狗的名字是"+getName()+",年龄是"+getAge()+"岁,凶猛程度是"+violence+"度");
    }
    @Override
    public void speak() {
        System.out.println("旺旺");
    }
}
class Cat4 extends Animal4 {
    int mousingAbility;
    public Cat4(String name, int age, int mousingAbility) {
        super(name, age);
        this.mousingAbility = mousingAbility;
    }
    @Override
    public void info() {
        System.out.println("该猫的名字是"+getName()+",年龄是"+getAge()+"岁,捕鼠能力是"+mousingAbility+"分");
    }
    @Override
    public void speak() {
        System.out.println("喵喵");
    }
}
class Factory4 {
    public Animal4 getAnimalByType(int type, String name, int age, int ownAttribute) {
        if(type == 1)
            return new Dog4(name,age,ownAttribute);

        else
            return new Cat4(name,age,ownAttribute);
    }
}
public class t4 {
    public static void main(String[] args) {
        Factory4 factory=new Factory4();
        Scanner input=new Scanner(System.in);
        int type=input.nextInt();
        String name=input.next();
        int age=input.nextInt();
        int ownAttribute=input.nextInt();
        Animal4 a=factory.getAnimalByType(type, name, age, ownAttribute);
        a.info();
        a.speak();
        System.out.println(a.getName());
        System.out.println(a.getAge());
        input.close();
    }
}
